﻿using JMI_Nucleo.JMIProvider;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CronosUtil
{
    public partial class FrmConEmpresaTeste : JMI_Nucleo.View.Form_Base.FrmBaseConsultaPaginada
    {
        public FrmConEmpresaTeste()
        {
            InitializeComponent();
        }

        private void FrmConEmpresaTeste_Load(object sender, EventArgs e)
        {
            EngineBD.Conectar();

            if (EngineBD.GetConexao != null && EngineBD.GetConexao.State == ConnectionState.Open)
            {
                base.ConexaoBD = EngineBD.GetConexao;
                base.CarregaDataSet();
                base.CarregaGrid();

                dgvConEmpresa.AutoGenerateColumns = false;
                dgvConEmpresa.ReadOnly = true;
                dgvConEmpresa.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

                dgvConEmpresa.DataSource = base.bsConsulta;
                dgvConEmpresa.Refresh();

                pnlDetalhe.Visible = true;
                LigaControle();
            }
        }

        private void LigaControle()
        {
            //SELECT A.codigo, A.datacadastro, P.nome, P.apelido, P.CNPJ,
            //C.telefone1, C.telefone2, C.telefone3, C.celular, C.fax, C.email, C.email1,
            //C.site, C.fonecomercial
            lblRazaoSocial.DataBindings.Add("Text", base.bsConsulta, "nome"); 
        }

        private void FrmConEmpresaTeste_FormClosing(object sender, FormClosingEventArgs e)
        {
            EngineBD.Desconectar();
        }
    }
}
